package com.study.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.project.entity.RoleDO;
import com.study.project.mapper.RoleMapper;
import com.study.project.service.RolesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleDO> implements RolesService {
    @Resource
    private RoleMapper roleMapper;

    @Override
    public List<String> getRoleByIds(List<Integer> roleIds) {
        LambdaQueryWrapper<RoleDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(RoleDO::getRoleId, roleIds);
        return roleMapper.selectList(queryWrapper).parallelStream().map(RoleDO::getRoleName).collect(Collectors.toList());
    }
}
